/*
 * To change this license header, choose License Headers in Project Properties.
 * To change this template file, choose Tools | Templates
 * and open the template in the editor.
 */
package br.jm.mala.entity;

import java.io.Serializable;
import java.util.List;
import javax.persistence.Basic;
import javax.persistence.Column;
import javax.persistence.Entity;
import javax.persistence.GeneratedValue;
import javax.persistence.GenerationType;
import javax.persistence.Id;
import javax.persistence.JoinColumn;
import javax.persistence.JoinTable;
import javax.persistence.ManyToMany;
import javax.persistence.Table;
import javax.validation.constraints.Size;
import org.hibernate.annotations.LazyCollection;
import org.hibernate.annotations.LazyCollectionOption;

/**
 *
 * @author joao
 */
@Entity
@Table(name = "Categoria", catalog = "mala", schema = "dbo")
public class Categoria implements Serializable {
    private static final long serialVersionUID = -4466691053219792263L;
    @Id
    @GeneratedValue(strategy = GenerationType.IDENTITY)
    @Basic(optional = false)
    @Column(name = "id_categoria", nullable = false)
    private Integer idCategoria;
    @Size(max = 200)
    @Column(name = "dsc_categoria", nullable = false,length = 200)
    private String dscCategoria;
    @JoinTable(name = "grupo_categoria", joinColumns = {
        @JoinColumn(name = "id_categoria", referencedColumnName = "id_categoria", nullable = false)}, inverseJoinColumns = {
        @JoinColumn(name = "id_grupo", referencedColumnName = "id_grupo", nullable = false)})
    @ManyToMany
    @LazyCollection(LazyCollectionOption.FALSE)
    private List<CategoriaGrupo> categoriaGrupoList;

    public Categoria() {
    }

    public Categoria(Integer idCategoria) {
        this.idCategoria = idCategoria;
    }

    public Integer getIdCategoria() {
        return idCategoria;
    }

    public void setIdCategoria(Integer idCategoria) {
        this.idCategoria = idCategoria;
    }

    public String getDscCategoria() {
        return dscCategoria;
    }

    public void setDscCategoria(String dscCategoria) {
        this.dscCategoria = dscCategoria;
    }

    public List<CategoriaGrupo> getCategoriaGrupoList() {
        return categoriaGrupoList;
    }

    public void setCategoriaGrupoList(List<CategoriaGrupo> categoriaGrupoList) {
        this.categoriaGrupoList = categoriaGrupoList;
    }

    @Override
    public int hashCode() {
        int hash = 0;
        hash += (idCategoria != null ? idCategoria.hashCode() : 0);
        return hash;
    }

    @Override
    public boolean equals(Object object) {
        // TODO: Warning - this method won't work in the case the id fields are not set
        if (!(object instanceof Categoria)) {
            return false;
        }
        Categoria other = (Categoria) object;
        return !((this.idCategoria == null && other.idCategoria != null) || (this.idCategoria != null && !this.idCategoria.equals(other.idCategoria)));
    }

    @Override
    public String toString() {
        return "br.jm.mala.entity.Categoria[ idCategoria=" + idCategoria + " ]";
    }
    
}
